﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AvatarHelper;
using Avatar.MembershipService;
using Avatar.ResumeService;

public partial class PersonSelfEvaluation : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PersonHelper.BasicInformationJobIntentionCheck();

        if (!IsPostBack)
        {
            if (LoginManager.GetCurrentUser() != null)
            {
                var _user = LoginManager.GetCurrentUser();
                using (var _adc = DBHelper.GetDataContext())
                {
                    var _resume = _adc.Resume.Where(r => r.User == _user.UserName).FirstOrDefault();

                    if (_resume != null)
                    {
                        txt_SelfEvaluation.Text = _resume.SelfEvaluation == null ? string.Empty : _resume.SelfEvaluation.Evaluation;
                    }
                }
            }
        }
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        try
        {
            if(LoginManager.GetCurrentUser()!=null)
            SelfEvaluationManager.Save(LoginManager.GetCurrentUser().UserName, txt_SelfEvaluation.Text);

            Response.Redirect("./PersonResume.aspx");
        }
        catch (Exception _e)
        {
            lbl_Error.Text = _e.Message;
        }
    }
}
